﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

namespace DAO
{
    public class LopDAO
    {
        public static DataTable LayDuLieu()
        {
            string command = "select * from Lop";

            DataTable tb = new DataTable();
            try
            {
                tb = DaTaProvider.excecuteQuery(command);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return tb;
        }

        public static bool XoaLop(string tenLop)
        {

            string command = "delete Lop"
                            + " where Lop.maLop = '" +tenLop + "'";
            int i = 0;
            try
            {
               i =  DaTaProvider.ExcecuteNonQuery(command);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if( i > 0 )
                return true;
            return false;
        }

        public static bool ThemLop(string tenLop)
        { 
            
             string command = "insert into Lop( maLop, maGVCN, siSo )"
                             + "values ( '" + tenLop +"'," + "null,null )";
             try
            {
                 DaTaProvider.ExcecuteNonQuery(command);
            }
            catch (Exception ex)
            {
                return false;
            }
             return true;
        }

    }
}
